<?

if ($c = stack('name')) {

	$_id_component	= $DATA['components'][$c]['id'];			//	list id value
	$_id_data		= D_MB_DATA;			//	meta id value
	$_id_meta		= D_MB_META;			//	meta id value
	
	$_crit = "id_data=$_id_data AND id_parent=$_id_component AND attr & ".AA_VISIBLE;


	$s = array_extend( array('path' => 'article', 'w' => 128, 'h' => 96, 'param' => 'id', 'caption' => '', 'perPage' => 5, 'showBody' => '', 'showDate' => ''), $DATA['components'][$c]['settings']);

	$s['path'] = createdir(FP_UPLOAD_PATH.$s['path'].'/');
	$s['h'] = (int)$s['h'];
	$s['w'] = (int)$s['w'];

	$num = datafetch('db_item', tb('data'), $_crit, "COUNT(*) as num");

	if ($num = $num['num']) {
		$DATA['components'][$c]['settings']['paging'] = createPaging(array(
			'num' => $num, 
			'page' => param('page'), 
			'perPage' => $s['perPage']
		));
	
		$DATA['components'][$c]['data'] = array_mark_bounds( datafetch_array('db_list', array(
			'table' => tb('data'), 
			'where' => $_crit,	
			'order' => 'id_index', 
			'index' => 'id', 
			'limit' => $DATA['components'][$c]['settings']['paging']['limit'] 
		)));
	
		foreach($DATA['components'][$c]['data'] as $k => $v) {
			$DATA['components'][$c]['data'][$k] = array_merge($v, datafetch_array('meta', $_id_meta, $k, $CONTEXT['lang']));
			$DATA['components'][$c]['data'][$k]['image'] = checkImage($s['path'], $k);
			$DATA['components'][$c]['data'][$k]['date'] = format_simple_date($v['date_create']);
		}
	
	} else 
		$DATA['components'][$c]['data'] = array();

	unstack();
}

?>